package com.example.photography.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 提取的listview适配器
 * @param <T>
 */

public abstract class MyBaseAdapter<T> extends BaseAdapter {

    public List<T> list;
    public Context mContext;
    //通过构造器初始化集合数据
    public MyBaseAdapter(List<T> list,Context context) {
        this.list = list;
        mContext = context;
    }

    //刷新数据
    public void refresh(List<T> lists){
        if (lists!=null&&lists.size()>0){
//            list.clear();
//            list.addAll(lists);
            //刷新
            notifyDataSetChanged();
        }

    }

    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = myGetView(position,convertView);
        return view;
    }

    public abstract View myGetView(int position, View convertView) ;
}
